home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / multiview.e < prev    next >
Text File  |  1995-07-16  |  5KB  |  152 lines

  1. /* 
  2. Introduction
  3. ------------
  4. This little program should be named MultiView and placed in the C: directory.
  5. It was written out of frustration. If you are using OS 2.x and often download
  6. archives from Aminet or the like, you probably know this situation: doubleclick
  7. on an icon and a requester pops up "program multiview cannot be located".
  8. Here is where this program comes in. It is called instead of the 3.x multiview
  9. and for all the usual file extensions there is a configured viewer that you like
  10. best.
  11.  
  12. How to use it?
  13. --------------
  14. Very simple, if you have AmigaE by Wouter van Oortmerssen. 
  15. Thanks Wouter for this incredible piece of software and the support!
  16. It was written using version 3.1a, but might work with earlier versions too. 
  17. (If not, get the latest version from Aminet and try the demo and register 
  18. afterwards 8-) )
  19. I put in my favourite viewers (players can also be used). To change that, just
  20. edit the source code to fit your needs and compile it. As the last step, put it
  21. in your C: directory as MultiView. Now you are set
  22.  
  23. Some problems
  24. -------------
  25. - viewers must be in C: or given with complete path, when used from WB
  26.   (DOS.library`s Execute function related)
  27.   (any ideas for fixing, please contact me)
  28. - doesn`t replace OS 3.x data types
  29.   (it doesn`t even try 8-( )
  30. - no external prefs file/program
  31.   (faster for same reason)
  32. - can handle only commands up to 512 characters (including parameters, quotes...)
  33.   (max. CLI command length is 512)
  34. - file needs to have an extension (.something)
  35.   (currently up to 6 characters)
  36.  
  37. Legal Stuff
  38. -----------
  39. This program was written, using some example routines from the AmigaE_v3.1a package,
  40. (thanks again to Wouter) by: Horst Schumann
  41.                              Helmstedter Str. 18
  42.                              39167 Irxleben
  43.                              Germany
  44.  
  45.                              e-mail: hschuman@cs.uni-magdeburg.de
  46.                  WWW: http://www.cs.uni-magddeburg.de/~hschuman/hschuman.html
  47.  
  48. I call it anythingware! Everybody can use it, modify it, compile it, re-release it,
  49. etc. provided he/she (Are there any girls using the Amiga? Love to hear from you!)
  50. sends me anything like e-mails, postcards, letters, money, Amigas (no PCs, please!), 
  51. etc., but if you can`t afford any of it, please use it anyway, it might be useful.
  52. Own programs, especially those of the useful kind, are very much welcome too.
  53.  
  54. And now the standard disclaimer
  55. -------------------------------
  56. NO WARRANTY
  57. If something happens you don`t want, blame somebody else!
  58.  
  59. Future Plans?
  60. -------------
  61. Who knows what the future will bring...
  62. */
  63.  
  64.  
  65.  
  66. OPT OSVERSION=37
  67.  
  68. MODULE 'workbench/startup'
  69.  
  70.  
  71. PROC get_extension(string,extension)
  72.   DEF pos
  73.   pos:=StrLen(string)-1
  74.   WHILE string[pos]<>"."
  75.     pos--
  76.   ENDWHILE
  77.   MidStr(extension,string,pos+1)
  78. ENDPROC
  79.  
  80.  
  81. PROC get_command(extension,command)     -> add own commands in this procedure
  82.   LowerStr(extension)
  83.   IF StrCmp(extension,'guide')
  84.     StrCopy(command,'amigaguide "')
  85.   ELSEIF StrCmp(extension,'doc')
  86.     StrCopy(command,'muchmore "')
  87.   ELSEIF StrCmp(extension,'txt')
  88.     StrCopy(command,'muchmore "')
  89.   ELSEIF StrCmp(extension,'readme')
  90.     StrCopy(command,'muchmore "')
  91.   ELSEIF StrCmp(extension,'iff')
  92.     StrCopy(command,'work:utilities/display "')
  93.   ELSEIF StrCmp(extension,'ham')
  94.     StrCopy(command,'work:utilities/display "')
  95.   ELSE
  96.     WriteF('File type unknown: \s\nusing default viewer\n',extension)
  97.     StrCopy(command,'muchmore "')
  98.   ENDIF
  99. ENDPROC
  100.  
  101.  
  102. PROC main()
  103.   DEF wb:PTR TO wbstartup       -> pointer to WBstartup object
  104.   DEF wbargs:PTR TO wbarg       -> pointer to WBarg object
  105.   DEF a                         -> just a counter
  106.   DEF template                  -> template for CLI argument parsing
  107.   DEF rdargs                    -> flag for ReadArgs result
  108.   DEF cliargs=NIL:PTR TO LONG   -> pointer where ReadArgs can store arguments
  109.   DEF command[512]:STRING       -> max. CLI command string length is 511
  110.   DEF currentdir                -> save current dir when started from WB
  111.   DEF ext[6]:STRING             -> extension
  112.   
  113.   IF wbmessage=NIL                              -> started from CLI
  114.     template:='FILE/M'
  115.     rdargs:=ReadArgs(template,{cliargs},NIL)
  116.     IF rdargs
  117.       IF cliargs
  118.         a:=0
  119.         WHILE cliargs[a]                    -> Loop through arguments
  120.           IF InStr(cliargs[a],'.') > -1
  121.             get_extension(cliargs[a],ext)
  122.             get_command(ext,command)
  123.           ENDIF
  124.           StrAdd(command,cliargs[a])
  125.           StrAdd(command,'"')
  126.           Execute(command,0,stdout)
  127.           a++
  128.         ENDWHILE
  129.       ENDIF
  130.       FreeArgs(rdargs)
  131.     ENDIF
  132.   ELSE                                              -> started from WB
  133.     currentdir:=CurrentDir(wbargs[0].lock)
  134.     wb:=wbmessage
  135.     wbargs:=wb.arglist
  136.     FOR a:=1 TO wb.numargs-1
  137.       IF InStr(wbargs[a].name,'.') > -1
  138.         get_extension(wbargs[a].name,ext)
  139.         get_command(ext,command)
  140.       ENDIF
  141.       CurrentDir(wbargs[a].lock)
  142.       StrAdd(command,wbargs[a].name)
  143.       StrAdd(command,'"')
  144.       Execute(command,0,stdout)
  145.     ENDFOR
  146.     CurrentDir(currentdir)
  147.     IF stdout<>NIL
  148.       WriteF('\n\nPress RETURN to close this window.\n')
  149.     ENDIF
  150.   ENDIF
  151. ENDPROC
  152.